<template>
  <Teleport to="body">
    <Transition name="modal-fade">
      <div v-if="show" class="permission-modal-overlay" @click="handleClose">
        <div class="permission-modal" @click.stop>
          <!-- 可爱的装饰元素 -->
          <div class="decoration-top">
            <div class="star star-1">⭐</div>
            <div class="star star-2">✨</div>
            <div class="star star-3">💫</div>
          </div>
          
          <!-- 图标区域 -->
          <div class="icon-wrapper">
            <div class="lock-icon">
              <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 2C9.243 2 7 4.243 7 7v2H6c-1.103 0-2 .897-2 2v9c0 1.103.897 2 2 2h12c1.103 0 2-.897 2-2v-9c0-1.103-.897-2-2-2h-1V7c0-2.757-2.243-5-5-5zm0 2c1.654 0 3 1.346 3 3v2H9V7c0-1.654 1.346-3 3-3zm-6 7h12l.002 9H6v-9z" fill="currentColor"/>
                <circle cx="12" cy="16" r="2" fill="currentColor"/>
              </svg>
            </div>
            <div class="icon-circle"></div>
          </div>
          
          <!-- 标题 -->
          <h3 class="modal-title">{{ title }}</h3>
          
          <!-- 消息 -->
          <p class="modal-message">{{ message }}</p>
          
          <!-- 额外提示 -->
          <div class="tips">
            <div class="tip-item">
              <span class="tip-icon">💝</span>
              <span>请联系管理员获取权限</span>
            </div>
          </div>
          
          <!-- 按钮 -->
          <button class="confirm-btn" @click="handleClose">
            <span>知道了</span>
            <span class="btn-sparkle">✨</span>
          </button>
          
          <!-- 底部装饰 -->
          <div class="decoration-bottom">
            <div class="wave"></div>
            <div class="hearts">
              <span class="heart">💗</span>
              <span class="heart">💖</span>
              <span class="heart">💝</span>
            </div>
          </div>
        </div>
      </div>
    </Transition>
  </Teleport>
</template>

<script setup>
import { ref, watch } from 'vue'

const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    default: '权限不足 (｡•́︿•̀｡)'
  },
  message: {
    type: String,
    default: '抱歉～您没有访问此功能的权限哦'
  }
})

const emit = defineEmits(['update:modelValue', 'close'])

const show = ref(props.modelValue)

watch(() => props.modelValue, (newVal) => {
  show.value = newVal
})

const handleClose = () => {
  show.value = false
  emit('update:modelValue', false)
  emit('close')
}
</script>

<style scoped>
.permission-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.permission-modal {
  position: relative;
  background: linear-gradient(135deg, #fff5f7 0%, #ffe4e8 100%);
  border-radius: 24px;
  padding: 40px 30px 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: 
    0 20px 60px rgba(255, 105, 180, 0.4),
    0 0 0 1px rgba(255, 182, 193, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 顶部装饰星星 */
.decoration-top {
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
}

.star {
  font-size: 20px;
  animation: twinkle 2s ease-in-out infinite;
}

.star-1 {
  animation-delay: 0s;
}

.star-2 {
  animation-delay: 0.5s;
}

.star-3 {
  animation-delay: 1s;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.2) rotate(180deg);
  }
}

/* 图标区域 */
.icon-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
}

.icon-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #FFB6C1 0%, #FF69B4 100%);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 
    0 8px 25px rgba(255, 105, 180, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

@keyframes pulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
}

.lock-icon {
  position: relative;
  z-index: 2;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-icon svg {
  width: 50px;
  height: 50px;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  animation: lockShake 3s ease-in-out infinite;
}

@keyframes lockShake {
  0%, 100% {
    transform: rotate(0deg);
  }
  10%, 30% {
    transform: rotate(-5deg);
  }
  20%, 40% {
    transform: rotate(5deg);
  }
  50%, 90% {
    transform: rotate(0deg);
  }
}

/* 标题 */
.modal-title {
  font-size: 24px;
  font-weight: 700;
  color: #FF1493;
  text-align: center;
  margin: 0 0 15px 0;
  text-shadow: 0 2px 4px rgba(255, 20, 147, 0.2);
  letter-spacing: 1px;
}

/* 消息 */
.modal-message {
  font-size: 16px;
  color: #666;
  text-align: center;
  margin: 0 0 25px 0;
  line-height: 1.6;
}

/* 提示区域 */
.tips {
  background: white;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 25px;
  border: 2px solid #FFE4E1;
  box-shadow: 0 2px 8px rgba(255, 182, 193, 0.2);
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #FF69B4;
  font-size: 14px;
  font-weight: 500;
}

.tip-icon {
  font-size: 20px;
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.2);
  }
  50% {
    transform: scale(1);
  }
}

/* 按钮 */
.confirm-btn {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, #FF69B4 0%, #FF1493 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 
    0 4px 15px rgba(255, 20, 147, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.confirm-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.confirm-btn:hover::before {
  left: 100%;
}

.confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 20px rgba(255, 20, 147, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.confirm-btn:active {
  transform: translateY(0);
  box-shadow: 
    0 2px 10px rgba(255, 20, 147, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-sparkle {
  display: inline-block;
  animation: sparkleRotate 2s linear infinite;
}

@keyframes sparkleRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 底部装饰 */
.decoration-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
}

.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(135deg, #FFB6C1 0%, #FF69B4 100%);
  opacity: 0.3;
  border-radius: 0 0 24px 24px;
}

.hearts {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 15px;
}

.heart {
  font-size: 16px;
  animation: float 3s ease-in-out infinite;
}

.heart:nth-child(1) {
  animation-delay: 0s;
}

.heart:nth-child(2) {
  animation-delay: 0.5s;
}

.heart:nth-child(3) {
  animation-delay: 1s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* 过渡动画 */
.modal-fade-enter-active,
.modal-fade-leave-active {
  transition: opacity 0.3s ease;
}

.modal-fade-enter-from,
.modal-fade-leave-to {
  opacity: 0;
}

.modal-fade-enter-active .permission-modal {
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-fade-leave-active .permission-modal {
  animation: modalSlideOut 0.3s ease-out;
}

@keyframes modalSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
}

/* 响应式 */
@media (max-width: 480px) {
  .permission-modal {
    padding: 30px 20px 25px;
    margin: 10px;
  }
  
  .modal-title {
    font-size: 20px;
  }
  
  .modal-message {
    font-size: 14px;
  }
}
</style>
